﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HtmlAgilityPack;

namespace ZCrawler
{
    public class ZCrawlDataHrefParser : ZCrawlDataProcessor
    {
        public override string Process(string str)
        {
            string val = "";
            try
            {
                HtmlDocument d = new HtmlDocument() { OptionAutoCloseOnEnd = true, OptionOutputAsXml = true };
                d.LoadHtml(str);
                val = d.DocumentNode.Element("a").GetAttributeValue("href", "unknown");
            }
            catch (Exception ex) { }
            return val;
        }

        public override string Description
        {
            get
            {
                return "Href Parser";
            }
            set
            {
                base.Description = value;
            }
        }
    }
}
